<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改合同分类')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-type-edit" th:object="${contractType}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">分类名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">英文名称：</label>
                <div class="col-sm-8">
                    <input name="englishName" th:field="*{englishName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">图片：</label>
                <div class="col-sm-8">
                    <input id="filePath" name="filePath" class="form-control" type="file">
                    <input id="pictureUrl" name="pictureUrl" th:field="*{pictureUrl}" type="text" hidden>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">图片2：</label>
                <div class="col-sm-8">
                    <input id="filePath2" name="filePath2" class="form-control" type="file">
                    <input id="pictureUrl2" name="pictureUrl2" th:field="*{pictureUrl2}" type="text" hidden>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "front/contractType";
        $("#form-type-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                if ($('#filePath')[0].files[0] != null) {
                    let result = uploadFile(false, "pictureUrl");
                    if (result != web_status.SUCCESS) {
                        return;
                    }
                }

                if ($('#filePath2')[0].files[0] != null) {
                    let result2 = uploadMoreFile(false, "pictureUrl2", "filePath2");
                    if (result2 != web_status.SUCCESS) {
                        return;
                    }
                }
                $.operate.save(prefix + "/edit", $('#form-type-edit').serialize());
            }
        }
    </script>
</body>
</html>